<html>
<head><meta charset="utf-8"><title>type parameter out of range #55872 · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html">type parameter out of range #55872</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="168064482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064482">(Jun 13 2019 at 17:07)</a>:</h4>
<p>hi <span class="user-mention" data-user-id="116107">@davidtwco</span></p>



<a name="168064521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064521">(Jun 13 2019 at 17:07)</a>:</h4>
<p><span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="168064555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064555">(Jun 13 2019 at 17:07)</a>:</h4>
<p>let's try zulip</p>



<a name="168064609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064609">(Jun 13 2019 at 17:08)</a>:</h4>
<p>better logs..plus I have a lot of calls today and that always wears me out</p>



<a name="168064641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064641">(Jun 13 2019 at 17:08)</a>:</h4>
<p>right...so...</p>



<a name="168064652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064652">(Jun 13 2019 at 17:08)</a>:</h4>
<p>it occurs to me I'm not 100% sure how much you understand about the type parameters etc</p>



<a name="168064663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064663">(Jun 13 2019 at 17:08)</a>:</h4>
<p>i.e., you're familiar with the general system of "substs" in the compiler?</p>



<a name="168064681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064681">(Jun 13 2019 at 17:09)</a>:</h4>
<p>I think so yeah.</p>



<a name="168064732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064732">(Jun 13 2019 at 17:09)</a>:</h4>
<p>ok. So the general idea (just to review real briefly) is that when you have a type parameter type like <code>X</code>, it includes an index into the parameters in scope</p>



<a name="168064821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064821">(Jun 13 2019 at 17:10)</a>:</h4>
<p>When we do a substitution, if you have e.g., <code>struct Foo&lt;T&gt; { t: T }</code> and you access the field <code>t</code>, it's type is a <code>Param(0)</code> (say) -- and then we have the substs array (maybe <code>[u32]</code>)</p>



<a name="168064837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064837">(Jun 13 2019 at 17:10)</a>:</h4>
<p>and we index into that array with the <code>0</code> offset to convert <code>T</code> to <code>u32</code> (presuming <code>Foo&lt;u32&gt;</code>)</p>



<a name="168064844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064844">(Jun 13 2019 at 17:10)</a>:</h4>
<p>(all familiar?)</p>



<a name="168064856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064856">(Jun 13 2019 at 17:10)</a>:</h4>
<p>so the reason I'm worried is that an out of range error here <em>usually</em> means we failed to substitute somewhere</p>



<a name="168064869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064869">(Jun 13 2019 at 17:10)</a>:</h4>
<p>and hence a <code>TyParam</code> with an index meant for one set of generics</p>



<a name="168064872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064872">(Jun 13 2019 at 17:11)</a>:</h4>
<p>leaks into a scope with a different set</p>



<a name="168064887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064887">(Jun 13 2019 at 17:11)</a>:</h4>
<p>(though it could have other causes)</p>



<a name="168064897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064897">(Jun 13 2019 at 17:11)</a>:</h4>
<blockquote>
<p>leaks into a scope with a different set</p>
</blockquote>
<p>but if such a leak happens...badness</p>



<a name="168064987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168064987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168064987">(Jun 13 2019 at 17:12)</a>:</h4>
<p>anyway I guess the first step is to get a backtrace for the ICE</p>



<a name="168065020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065020">(Jun 13 2019 at 17:12)</a>:</h4>
<p><a href="https://gist.github.com/davidtwco/4f0bf9ff3aad9df25c272909492e6982" target="_blank" title="https://gist.github.com/davidtwco/4f0bf9ff3aad9df25c272909492e6982">https://gist.github.com/davidtwco/4f0bf9ff3aad9df25c272909492e6982</a></p>



<a name="168065023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065023">(Jun 13 2019 at 17:12)</a>:</h4>
<p>although the minimized form that was given doesn't build for me</p>



<a name="168065055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065055">(Jun 13 2019 at 17:13)</a>:</h4>
<p>hmm this error is very confusing</p>



<a name="168065059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065059">(Jun 13 2019 at 17:13)</a>:</h4>
<p>oh I forgot the edition</p>



<a name="168065074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065074">(Jun 13 2019 at 17:13)</a>:</h4>
<p>Though, my build for this is maybe a week old at this point, so the actual output may have changed.</p>



<a name="168065089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065089">(Jun 13 2019 at 17:13)</a>:</h4>
<p>right so I'm skimming past tall the type folder stuff</p>



<a name="168065114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065114">(Jun 13 2019 at 17:14)</a>:</h4>
<p>and I guess the real "source" of the error is here</p>
<div class="codehilite"><pre><span></span>rustc_typeck::collect::find_existential_constraints::ConstraintLocator::check
</pre></div>



<a name="168065152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065152">(Jun 13 2019 at 17:14)</a>:</h4>
<p>I landed on <code>typeck/collect.rs:1549</code> as being the place to start.</p>



<a name="168065161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065161">(Jun 13 2019 at 17:14)</a>:</h4>
<p>seems right</p>



<a name="168065189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065189">(Jun 13 2019 at 17:14)</a>:</h4>
<p>so what happens here --</p>



<a name="168065195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065195">(Jun 13 2019 at 17:14)</a>:</h4>
<p>this is the code for an <code>existential type</code> (opaque type)</p>



<a name="168065217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065217">(Jun 13 2019 at 17:15)</a>:</h4>
<p>the idea is that we have some hidden type whose value has been inferred</p>



<a name="168065220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065220">(Jun 13 2019 at 17:15)</a>:</h4>
<p>that is the <code>concrete_type</code> variable</p>



<a name="168065223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065223">(Jun 13 2019 at 17:15)</a>:</h4>
<p>and we are inferring its result</p>



<a name="168065232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065232">(Jun 13 2019 at 17:15)</a>:</h4>
<p>looking more closely at this, I am guessing this is a bug in the handling of <code>existential type</code> as an associated type definition in an impl</p>



<a name="168065234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065234">(Jun 13 2019 at 17:15)</a>:</h4>
<p>and <em>probably</em> not that specific to impl trait</p>



<a name="168065247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065247">(Jun 13 2019 at 17:15)</a>:</h4>
<p>but I guess let's wait a bit before we know if that's true</p>



<a name="168065253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065253">(Jun 13 2019 at 17:15)</a>:</h4>
<p>I believe the <code>concrete_type</code> was <code>impl std::future::Future</code> when I was looking at the logs (but rebuilding so can't check exactly).</p>



<a name="168065305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065305">(Jun 13 2019 at 17:16)</a>:</h4>
<p>And the <code>substs</code> just <code>[S]</code>.</p>



<a name="168065309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065309">(Jun 13 2019 at 17:16)</a>:</h4>
<p>ok, that's interesting</p>



<a name="168065313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065313">(Jun 13 2019 at 17:16)</a>:</h4>
<p>this version of the example also ICEs in a very similar way</p>



<a name="168065316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065316">(Jun 13 2019 at 17:16)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Bar</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">E</span>: <span class="nb">Copy</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">E</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">S</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">existential</span><span class="w"> </span><span class="k">type</span> <span class="nc">E</span>: <span class="nb">Copy</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">E</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="o">||</span><span class="w"> </span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>



<a name="168065323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065323">(Jun 13 2019 at 17:16)</a>:</h4>
<p>it does not use any async :)</p>



<a name="168065365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065365">(Jun 13 2019 at 17:17)</a>:</h4>
<p>I get:</p>
<div class="codehilite"><pre><span></span>error: internal compiler error: src/librustc/ty/subst.rs:570: type parameter `T/#1` (T/1) out of range when substituting (root type=Some([closure@/home/nmatsakis/tmp/issue-55872.rs:15:9: 15:14])) substs=[S]
</pre></div>



<a name="168065473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065473">(Jun 13 2019 at 17:18)</a>:</h4>
<p>but let's dig a <em>bit</em> more</p>



<a name="168065474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065474">(Jun 13 2019 at 17:18)</a>:</h4>
<p>let's use this version</p>



<a name="168065477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065477">(Jun 13 2019 at 17:18)</a>:</h4>
<p>less variables</p>



<a name="168065528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065528">(Jun 13 2019 at 17:19)</a>:</h4>
<div class="codehilite"><pre><span></span> concrete_type: [closure@/home/nmatsakis/tmp/issue-55872.rs:15:9: 15:14], substs: [S]
</pre></div>



<a name="168065531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065531">(Jun 13 2019 at 17:19)</a>:</h4>
<p>(from debug logs)</p>



<a name="168065547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065547">(Jun 13 2019 at 17:19)</a>:</h4>
<p>rerunnign with <code>-Zverbose</code></p>



<a name="168065552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065552">(Jun 13 2019 at 17:19)</a>:</h4>
<p>since closure types aren't that useful otherwise</p>



<a name="168065572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065572">(Jun 13 2019 at 17:19)</a>:</h4>
<p>gives</p>
<div class="codehilite"><pre><span></span>{ concrete_type:
    [closure@/home/nmatsakis/tmp/issue-55872.rs:15:9: 15:14
        closure_kind_ty=i8
        closure_sig_ty=extern &quot;rust-call&quot; fn(())
    ],
substs: [S] }
</pre></div>



<a name="168065682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065682">(Jun 13 2019 at 17:20)</a>:</h4>
<p>ok so</p>



<a name="168065685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065685">(Jun 13 2019 at 17:20)</a>:</h4>
<p>I think I see what's going on here</p>



<a name="168065716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065716">(Jun 13 2019 at 17:21)</a>:</h4>
<p>though it's not very evident from the debug output:)</p>



<a name="168065734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065734">(Jun 13 2019 at 17:21)</a>:</h4>
<p>first thing: closure types are implicitly parameterized by all of the generic types that are in scope</p>



<a name="168065742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065742">(Jun 13 2019 at 17:21)</a>:</h4>
<p>(same with async blocks)</p>



<a name="168065749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065749">(Jun 13 2019 at 17:21)</a>:</h4>
<p>this is because they may (e.g.) do things like <code>T::foo()</code></p>



<a name="168065762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065762">(Jun 13 2019 at 17:22)</a>:</h4>
<blockquote>
<p>though it's not very evident from the debug output:)</p>
</blockquote>
<p>this btw sucks and I wish we had time to make it better :)</p>



<a name="168065819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065819">(Jun 13 2019 at 17:22)</a>:</h4>
<p>the full set of closure substitutions therefore will be something like this:</p>



<a name="168065837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065837">(Jun 13 2019 at 17:22)</a>:</h4>
<div class="codehilite"><pre><span></span>[
    S, // from the impl
    T,  // from the function
    ... // some other stuff specific to closures, e.g., the type of the upvars (none in this case)
]
</pre></div>



<a name="168065867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065867">(Jun 13 2019 at 17:23)</a>:</h4>
<p>now the problem here is that, if you look at the example, the set of generics in scope at the <em>existential type</em> is just <code>S</code></p>



<a name="168065887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065887">(Jun 13 2019 at 17:23)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="w"> </span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">S</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">existential</span><span class="w"> </span><span class="k">type</span> <span class="nc">E</span>: <span class="nb">Copy</span><span class="p">;</span><span class="w"></span>
</pre></div>



<a name="168065978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065978">(Jun 13 2019 at 17:24)</a>:</h4>
<p>this is my preferred minimization</p>



<a name="168065982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065982">(Jun 13 2019 at 17:24)</a>:</h4>
<p>let's switch to this</p>



<a name="168065984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065984">(Jun 13 2019 at 17:24)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Bar</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">E</span>: <span class="nb">Copy</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">E</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="o">&lt;</span><span class="n">S</span>: <span class="nb">Default</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">S</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">existential</span><span class="w"> </span><span class="k">type</span> <span class="nc">E</span>: <span class="nb">Copy</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Default</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">E</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="p">(</span><span class="n">S</span>::<span class="n">default</span><span class="p">(),</span><span class="w"> </span><span class="n">T</span>::<span class="n">default</span><span class="p">())</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>



<a name="168065993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065993">(Jun 13 2019 at 17:24)</a>:</h4>
<p>here you can see that the return type from <code>foo</code> is <code>(S, T)</code></p>



<a name="168065998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168065998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168065998">(Jun 13 2019 at 17:24)</a>:</h4>
<p>but you see that there is no way that <code>E</code> could be equal to <code>(S, T)</code>, as <code>T</code> is not in scope there</p>



<a name="168066063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066063">(Jun 13 2019 at 17:25)</a>:</h4>
<p>there is some logic that's supposed to detect this</p>



<a name="168066076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066076">(Jun 13 2019 at 17:25)</a>:</h4>
<p>at least we spend a lot of effort to do it for lifetimes</p>



<a name="168066097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066097">(Jun 13 2019 at 17:26)</a>:</h4>
<p>perhaps we are not doing it for types, or not doing it very well</p>



<a name="168066191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066191">(Jun 13 2019 at 17:26)</a>:</h4>
<p>let's look where this <code>.concrete_existential_types</code> field is populated</p>



<a name="168066215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066215">(Jun 13 2019 at 17:27)</a>:</h4>
<p>i.e., we have this:</p>
<div class="codehilite"><pre><span></span><span class="w">          </span><span class="kd">let</span><span class="w"> </span><span class="n">ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="w"></span>
<span class="w">                </span><span class="p">.</span><span class="n">tcx</span><span class="w"></span>
<span class="w">                </span><span class="p">.</span><span class="n">typeck_tables_of</span><span class="p">(</span><span class="n">def_id</span><span class="p">)</span><span class="w"></span>
<span class="w">                </span><span class="p">.</span><span class="n">concrete_existential_types</span><span class="w"></span>
<span class="w">                </span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">.</span><span class="n">def_id</span><span class="p">);</span><span class="w"></span>
</pre></div>



<a name="168066224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066224">(Jun 13 2019 at 17:27)</a>:</h4>
<p>(earlier in that function)</p>



<a name="168066231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066231">(Jun 13 2019 at 17:27)</a>:</h4>
<p>for me, it's collect.rs:1551</p>



<a name="168066306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066306">(Jun 13 2019 at 17:28)</a>:</h4>
<p>I believe that this is populated in the <code>src/librustc_typeck/check/writeback.rs</code> -- are you familiar with "writeback"?</p>



<a name="168066350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066350">(Jun 13 2019 at 17:28)</a>:</h4>
<p>I've been in that file but I have yet to work out why it's called <code>writeback</code>, line 603 in that seems to populate <code>concrete_existential_types</code>.</p>



<a name="168066371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066371">(Jun 13 2019 at 17:29)</a>:</h4>
<p>it's called writeback because</p>



<a name="168066377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066377">(Jun 13 2019 at 17:29)</a>:</h4>
<p>when we type check a function</p>



<a name="168066385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066385">(Jun 13 2019 at 17:29)</a>:</h4>
<p>we first create a "local" set of information for it</p>



<a name="168066392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066392">(Jun 13 2019 at 17:29)</a>:</h4>
<p>this local set includes inference variables and a bunch of intermediate stuff</p>



<a name="168066399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066399">(Jun 13 2019 at 17:29)</a>:</h4>
<p>once all inference is done, we create the final version of the information without any inference variables</p>



<a name="168066402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066402">(Jun 13 2019 at 17:29)</a>:</h4>
<p>then we write that to the global tables</p>



<a name="168066412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066412">(Jun 13 2019 at 17:29)</a>:</h4>
<p>I guess "write<em>back</em>" is a bit strange, since it was never there before</p>



<a name="168066418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066418">(Jun 13 2019 at 17:29)</a>:</h4>
<p>I can't remember if we used to do it some other way</p>



<a name="168066450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066450">(Jun 13 2019 at 17:30)</a>:</h4>
<p>I guess "commit" might be a better name or something</p>



<a name="168066471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066471">(Jun 13 2019 at 17:30)</a>:</h4>
<p>anyway</p>



<a name="168066513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066513">(Jun 13 2019 at 17:30)</a>:</h4>
<p>right so this function:</p>



<a name="168066515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066515">(Jun 13 2019 at 17:30)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="w">           </span><span class="kd">let</span><span class="w"> </span><span class="n">definition_ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">generics</span><span class="p">.</span><span class="n">parent</span><span class="p">.</span><span class="n">is_some</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="c1">// `impl Trait`</span>
<span class="w">                </span><span class="bp">self</span><span class="p">.</span><span class="n">fcx</span><span class="p">.</span><span class="n">infer_opaque_definition_from_instantiation</span><span class="p">(</span><span class="w"></span>
<span class="w">                    </span><span class="n">def_id</span><span class="p">,</span><span class="w"></span>
<span class="w">                    </span><span class="n">opaque_defn</span><span class="p">,</span><span class="w"></span>
<span class="w">                    </span><span class="n">instantiated_ty</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="p">)</span><span class="w"></span>
</pre></div>



<a name="168066530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066530">(Jun 13 2019 at 17:30)</a>:</h4>
<p>that <code>infer_opaqe_definition_from_instantiation</code> has the job</p>



<a name="168066542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066542">(Jun 13 2019 at 17:30)</a>:</h4>
<p>well, wait up,</p>



<a name="168066550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066550">(Jun 13 2019 at 17:30)</a>:</h4>
<p><strong>in general</strong> what we want to do here</p>



<a name="168066558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066558">(Jun 13 2019 at 17:31)</a>:</h4>
<p>is to map from the "Local view" of the type</p>



<a name="168066576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066576">(Jun 13 2019 at 17:31)</a>:</h4>
<p>(the opaque type)</p>



<a name="168066580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066580">(Jun 13 2019 at 17:31)</a>:</h4>
<p>to the "definition" version</p>



<a name="168066586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066586">(Jun 13 2019 at 17:31)</a>:</h4>
<p>i.e., if you imagine</p>



<a name="168066604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066604">(Jun 13 2019 at 17:31)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="n">existential</span><span class="w"> </span><span class="k">type</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span>: <span class="nb">Sized</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="p">(</span><span class="n">a</span>: <span class="nc">A</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Foo</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">vec</span><span class="o">!</span><span class="p">[</span><span class="n">a</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="168066630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066630">(Jun 13 2019 at 17:31)</a>:</h4>
<p>then the "hidden type" is <code>Vec&lt;A&gt;</code>, from the point of view of <code>foo</code></p>



<a name="168066684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066684">(Jun 13 2019 at 17:32)</a>:</h4>
<p>but we want to express it in terms of the bounds of the <em>existential type</em>, so we want <code>Vec&lt;T&gt;</code></p>



<a name="168066697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066697">(Jun 13 2019 at 17:32)</a>:</h4>
<p>because this is the type that, when you substitute <code>T</code> for <code>A</code> (because we have <code>Foo&lt;A&gt;</code>), gives you <code>Vec&lt;A&gt;</code></p>



<a name="168066719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066719">(Jun 13 2019 at 17:32)</a>:</h4>
<p>in general, there may not be a unique reverse mapping</p>



<a name="168066749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066749">(Jun 13 2019 at 17:33)</a>:</h4>
<p>e.g., if you had <code>fn foo() -&gt; Foo&lt;u32&gt; { 22_u32 }</code></p>



<a name="168066766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066766">(Jun 13 2019 at 17:33)</a>:</h4>
<p>then <code>Foo&lt;T&gt;</code> could be either <code>T</code> or <code>u32</code></p>



<a name="168066770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066770">(Jun 13 2019 at 17:33)</a>:</h4>
<p>so we prohibit that :)</p>



<a name="168066796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066796">(Jun 13 2019 at 17:33)</a>:</h4>
<p>specifically, we require that the substitutions for <code>Foo</code> have to be fresh type parameters</p>



<a name="168066815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066815">(Jun 13 2019 at 17:33)</a>:</h4>
<p>that are not in scope for <code>Foo</code> itself</p>



<a name="168066894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066894">(Jun 13 2019 at 17:34)</a>:</h4>
<p>(this is called "pattern unification" instead of the more general "unification")</p>



<a name="168066902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066902">(Jun 13 2019 at 17:34)</a>:</h4>
<p>i.e., imposing this restriction</p>



<a name="168066904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066904">(Jun 13 2019 at 17:34)</a>:</h4>
<p>(it comes from lambda prolog, as it happens)</p>



<a name="168066913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066913">(Jun 13 2019 at 17:34)</a>:</h4>
<p>anyway, getting a bit afield here...</p>



<a name="168066919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066919">(Jun 13 2019 at 17:34)</a>:</h4>
<p>but the point is we have to do this reverse mapping</p>



<a name="168066949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066949">(Jun 13 2019 at 17:35)</a>:</h4>
<p>I'm not entirely sure which path we are going to go down in this file</p>



<a name="168066974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066974">(Jun 13 2019 at 17:35)</a>:</h4>
<p>i.e., we have</p>
<div class="codehilite"><pre><span></span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">generics</span><span class="p">.</span><span class="n">parent</span><span class="p">.</span><span class="n">is_some</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="c1">// impl Trait</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="168066979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066979">(Jun 13 2019 at 17:35)</a>:</h4>
<p>the comments suggest the first path is specific to <code>-&gt; impl Trait</code></p>



<a name="168066983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066983">(Jun 13 2019 at 17:35)</a>:</h4>
<p>but I think that's not true</p>



<a name="168066989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168066989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168066989">(Jun 13 2019 at 17:35)</a>:</h4>
<p>I imagine that is the path we are going to go down</p>



<a name="168067042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067042">(Jun 13 2019 at 17:36)</a>:</h4>
<p>do you know what <code>generics.parent</code> is?</p>



<a name="168067062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067062">(Jun 13 2019 at 17:36)</a>:</h4>
<p>(ok, I think I understand the bug fully now...)</p>



<a name="168067079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067079">(Jun 13 2019 at 17:36)</a>:</h4>
<p>Not really, if I had to guess, in our example <code>generics</code> would contain <code>T</code> and <code>generics.parent</code> is where <code>S</code> lives.</p>



<a name="168067095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067095">(Jun 13 2019 at 17:36)</a>:</h4>
<p>correct</p>



<a name="168067100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067100">(Jun 13 2019 at 17:36)</a>:</h4>
<p>well</p>



<a name="168067103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067103">(Jun 13 2019 at 17:37)</a>:</h4>
<p>sort of</p>



<a name="168067115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067115">(Jun 13 2019 at 17:37)</a>:</h4>
<p>this is indeed the role of parent</p>



<a name="168067118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067118">(Jun 13 2019 at 17:37)</a>:</h4>
<p>if you have nested scopes which inherit the generic parameters from an outer scope</p>



<a name="168067126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067126">(Jun 13 2019 at 17:37)</a>:</h4>
<p>then you get a "chain" of generics</p>



<a name="168067130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067130">(Jun 13 2019 at 17:37)</a>:</h4>
<p>so e.g. the generics for the method are <code>[T]</code></p>



<a name="168067132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067132">(Jun 13 2019 at 17:37)</a>:</h4>
<p>but they have a parent of <code>[S]</code></p>



<a name="168067144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067144">(Jun 13 2019 at 17:37)</a>:</h4>
<p>we don't often have such chains -- methods in impls are one of the few cases</p>



<a name="168067208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067208">(Jun 13 2019 at 17:38)</a>:</h4>
<p>in this particular case, though, the generics in question refers to the generics <em>on the existential type</em></p>



<a name="168067221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067221">(Jun 13 2019 at 17:38)</a>:</h4>
<p>so it's going to be <code>[]</code> here, but the parent will be the impl</p>



<a name="168067228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067228">(Jun 13 2019 at 17:38)</a>:</h4>
<p>(it is <code>[]</code> because we have <code>existential type Foo</code>, no generics)</p>



<a name="168067239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067239">(Jun 13 2019 at 17:38)</a>:</h4>
<p>(if we had <code>existential type Foo&lt;A&gt;</code>, it would be <code>[A]</code> (but that'd be GATs))</p>



<a name="168067255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067255">(Jun 13 2019 at 17:38)</a>:</h4>
<p>anyway the reason that it is checking the parent field</p>



<a name="168067278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067278">(Jun 13 2019 at 17:39)</a>:</h4>
<p>this is because we "desugar" <code>impl Trait</code> like so:</p>



<a name="168067293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067293">(Jun 13 2019 at 17:39)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">Trait</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="168067295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067295">(Jun 13 2019 at 17:39)</a>:</h4>
<p>becomes</p>



<a name="168067306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067306">(Jun 13 2019 at 17:39)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">existential</span><span class="w"> </span><span class="k">type</span> <span class="nc">Foo</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="168067309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067309">(Jun 13 2019 at 17:39)</a>:</h4>
<p>well, <em>something</em> like that</p>



<a name="168067318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067318">(Jun 13 2019 at 17:39)</a>:</h4>
<p>you couldn't actually write it, because scoping doesn't work that way</p>



<a name="168067379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067379">(Jun 13 2019 at 17:40)</a>:</h4>
<p>but the point is, we make the parent be the function, and it inherits the generic parameters from the parent</p>



<a name="168067401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067401">(Jun 13 2019 at 17:40)</a>:</h4>
<p>(there is a legendary hack here concerning lifetimes, but I'm going to ignore that for now)</p>



<a name="168067415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067415">(Jun 13 2019 at 17:40)</a>:</h4>
<blockquote>
<p>we make the parent be the function, and it inherits the generic parameters from the parent</p>
</blockquote>
<p>(<a href="https://www.microsoft.com/en-us/research/publication/lexically-scoped-type-variables/" target="_blank" title="https://www.microsoft.com/en-us/research/publication/lexically-scoped-type-variables/">https://www.microsoft.com/en-us/research/publication/lexically-scoped-type-variables/</a>)</p>



<a name="168067423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067423">(Jun 13 2019 at 17:40)</a>:</h4>
<p>this has an interesting implication, in the case of impl Trait</p>



<a name="168067483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067483">(Jun 13 2019 at 17:41)</a>:</h4>
<p>in particular, the <code>existential type Foo</code> that we introduce only ever has lifetime parameters on it. And, the  set of type parameters in scope at its definition (the function) are all <em>parameters the function shares with the existential type</em></p>



<a name="168067495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067495">(Jun 13 2019 at 17:41)</a>:</h4>
<p>in other words, we can just ignore types completely for the purpose of the "reverse mapping" check</p>



<a name="168067558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067558">(Jun 13 2019 at 17:42)</a>:</h4>
<p>put another way, the <code>-&gt; impl Trait</code> sugar always ensures all type parametesr that might appear in the hidden type are "in scope" (and have the same indices)</p>



<a name="168067574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067574">(Jun 13 2019 at 17:42)</a>:</h4>
<p>so you might get a clue where we are going wrong here now...</p>



<a name="168067641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067641">(Jun 13 2019 at 17:43)</a>:</h4>
<p>when this code was generalized to support <code>existential type Foo;</code> declarations,</p>



<a name="168067646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067646">(Jun 13 2019 at 17:43)</a>:</h4>
<p>we were distinguishing the <em>impl trait</em> case from the <em>more general case</em></p>



<a name="168067649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067649">(Jun 13 2019 at 17:43)</a>:</h4>
<p>(I'm not entirely sure why)</p>



<a name="168067664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067664">(Jun 13 2019 at 17:43)</a>:</h4>
<p>initially, we didn't support those in impls</p>



<a name="168067675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067675">(Jun 13 2019 at 17:43)</a>:</h4>
<p>so we just checked in <a href="http://writeback.rs" target="_blank" title="http://writeback.rs">writeback.rs</a> for whether there is a parent</p>



<a name="168067677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067677">(Jun 13 2019 at 17:43)</a>:</h4>
<p>if so, it is a nested "impl trait" item</p>



<a name="168067751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067751">(Jun 13 2019 at 17:44)</a>:</h4>
<p>and it <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/check/writeback.rs#L454-L458" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/check/writeback.rs#L454-L458">invokes the <code>infer_opaque_definition_from_instantiation</code> helper function</a> to check that the lifetimes involved have a reverse mapping</p>



<a name="168067756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067756">(Jun 13 2019 at 17:44)</a>:</h4>
<p>but this helper function ignores types</p>



<a name="168067777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067777">(Jun 13 2019 at 17:44)</a>:</h4>
<p>Does the same desugaring you described for <code>impl Trait</code>, where it is "defined" in the function apply when an existential type is an associated type like in our example then?</p>



<a name="168067794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067794">(Jun 13 2019 at 17:44)</a>:</h4>
<p>it is <a href="https://github.com/rust-lang/rust/blob/57a3300c2538fd1044ce45d9ef3b82182acb57ae/src/librustc/infer/opaque_types/mod.rs#L429-L434" target="_blank" title="https://github.com/rust-lang/rust/blob/57a3300c2538fd1044ce45d9ef3b82182acb57ae/src/librustc/infer/opaque_types/mod.rs#L429-L434">defined here</a></p>



<a name="168067825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067825">(Jun 13 2019 at 17:45)</a>:</h4>
<blockquote>
<p>Does the same desugaring you described for <code>impl Trait</code>, where it is "defined" in the function apply when an existential type is an associated type like in our example then?</p>
</blockquote>
<p>in some sense yes</p>



<a name="168067828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067828">(Jun 13 2019 at 17:45)</a>:</h4>
<p>because they share a prefix</p>



<a name="168067839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067839">(Jun 13 2019 at 17:45)</a>:</h4>
<p>of type parameters in common</p>



<a name="168067848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067848">(Jun 13 2019 at 17:45)</a>:</h4>
<p>and those type parameters don't need to be remapped, they're just in scope for both</p>



<a name="168067866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067866">(Jun 13 2019 at 17:45)</a>:</h4>
<p>but the difference is that, here, the method is introducing a <em>new</em> type parameter <code>T</code> that is not shraed</p>



<a name="168067940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168067940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168067940">(Jun 13 2019 at 17:46)</a>:</h4>
<p>if you look at the <a href="https://github.com/rust-lang/rust/blob/57a3300c2538fd1044ce45d9ef3b82182acb57ae/src/librustc_typeck/check/writeback.rs#L459" target="_blank" title="https://github.com/rust-lang/rust/blob/57a3300c2538fd1044ce45d9ef3b82182acb57ae/src/librustc_typeck/check/writeback.rs#L459">else path</a>, you can see we are <a href="https://github.com/rust-lang/rust/blob/57a3300c2538fd1044ce45d9ef3b82182acb57ae/src/librustc_typeck/check/writeback.rs#L491-L500" target="_blank" title="https://github.com/rust-lang/rust/blob/57a3300c2538fd1044ce45d9ef3b82182acb57ae/src/librustc_typeck/check/writeback.rs#L491-L500">checking that case</a></p>



<a name="168068004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068004">(Jun 13 2019 at 17:47)</a>:</h4>
<p>in contrast, the impl trait case goes down employs this <a href="https://github.com/rust-lang/rust/blob/57a3300c2538fd1044ce45d9ef3b82182acb57ae/src/librustc/infer/opaque_types/mod.rs#L662-L723" target="_blank" title="https://github.com/rust-lang/rust/blob/57a3300c2538fd1044ce45d9ef3b82182acb57ae/src/librustc/infer/opaque_types/mod.rs#L662-L723"><code>ReverseMapper</code> visitor</a></p>



<a name="168068023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068023">(Jun 13 2019 at 17:47)</a>:</h4>
<p>which just folds types</p>



<a name="168068027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068027">(Jun 13 2019 at 17:47)</a>:</h4>
<p>so I think the fix is to merge those two paths</p>



<a name="168068041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068041">(Jun 13 2019 at 17:47)</a>:</h4>
<p>(i'm not sure why they are separate at all)</p>



<a name="168068043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068043">(Jun 13 2019 at 17:47)</a>:</h4>
<p>maybe no good reason</p>



<a name="168068052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068052">(Jun 13 2019 at 17:47)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> might remember, they were doing some of this work</p>



<a name="168068123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068123">(Jun 13 2019 at 17:48)</a>:</h4>
<p>I think the check we want is basically:</p>
<ul>
<li>the type parameter should be part of the common prefix <em>or</em></li>
<li>should have a reverse mapping</li>
</ul>



<a name="168068206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068206">(Jun 13 2019 at 17:49)</a>:</h4>
<p>I'm wondering if we should use last few minutes to look at the other problem though :)</p>



<a name="168068231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068231">(Jun 13 2019 at 17:49)</a>:</h4>
<p>That's probably enough background on <a href="https://github.com/rust-lang/rust/issues/55872" target="_blank" title="https://github.com/rust-lang/rust/issues/55872">#55872</a> for me to attempt fixing it.</p>



<a name="168068236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068236">(Jun 13 2019 at 17:49)</a>:</h4>
<p>Thanks, this was very helpful.</p>



<a name="168068258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068258">(Jun 13 2019 at 17:50)</a>:</h4>
<p>I was thinking -- this would be good material to try and get into the rustc-guide</p>



<a name="168068320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068320">(Jun 13 2019 at 17:50)</a>:</h4>
<p>e.g., talking about how opaque types are implemented</p>



<a name="168068371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168068371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168068371">(Jun 13 2019 at 17:50)</a>:</h4>
<p>maybe I'll cc <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> -- do you have some kind of "queue" for things that might be good to add to the rustc-guide? If so, there is some coverage of the high-level view of opaque types in this thread that we might try to transcribe.</p>



<a name="168116093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168116093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168116093">(Jun 14 2019 at 08:17)</a>:</h4>
<p>so... When I implemented existential types I believed it would not work to merge the paths, but if we add the <code>ty::Param</code> and <code>ConstVal::Param</code> code to the visitor we should be able to do it</p>



<a name="168116126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168116126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168116126">(Jun 14 2019 at 08:17)</a>:</h4>
<p>it will end up doing some <code>T</code> by <code>T</code> replacements for <code>impl Trait</code>, but that should be fine.</p>



<a name="168145820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168145820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168145820">(Jun 14 2019 at 15:37)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> </p>
<blockquote>
<p>maybe I'll cc @Santiago Pastorino -- do you have some kind of "queue" for things that might be good to add to the rustc-guide? If so, there is some coverage of the high-level view of opaque types in this thread that we might try to transcribe.</p>
</blockquote>
<p>Currently it is just github issues, though we have been looking at other things. I opened <a href="https://github.com/rust-lang/rustc-guide/issues/339" target="_blank" title="https://github.com/rust-lang/rustc-guide/issues/339">https://github.com/rust-lang/rustc-guide/issues/339</a></p>



<a name="168158487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168158487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168158487">(Jun 14 2019 at 18:13)</a>:</h4>
<blockquote>
<p>maybe I'll cc <span class="user-mention silent" data-user-id="116266">Santiago Pastorino</span> -- do you have some kind of "queue" for things that might be good to add to the rustc-guide? If so, there is some coverage of the high-level view of opaque types in this thread that we might try to transcribe.</p>
</blockquote>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span>, cool that <span class="user-mention" data-user-id="198054">@mark-i-m</span> did open an issue :)</p>



<a name="168830692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/type%20parameter%20out%20of%20range%20%2355872/near/168830692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/type.20parameter.20out.20of.20range.20.2355872.html#168830692">(Jun 24 2019 at 08:19)</a>:</h4>
<p>Sorry for the delay here, had a busy week, submitted <a href="https://github.com/rust-lang/rust/issues/62090" target="_blank" title="https://github.com/rust-lang/rust/issues/62090">#62090</a> for this, <span class="user-mention" data-user-id="116009">@nikomatsakis</span>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>